package com.grep.extra.factory.data.impl;

import java.util.Collection;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import com.grep.extra.factory.data.IDataQueue;

/**
 * 对网站地址进行缓存的容器
 * @author tiamsw
 *
 * @param <T>
 */
public class DataQueue< IUrl> implements IDataQueue< IUrl>  {
	
	private BlockingQueue<IUrl> data = new  LinkedBlockingQueue<IUrl>();
	
	public void put(IUrl t) {
		try {
			data.put(t) ;
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	
	public IUrl take() {
		IUrl url = null ;
		try {
			url = data.take() ;
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return url ;
	}

	public int size() {
		return data.size();
	}


	public void putAll(Collection<IUrl> c) {
		data.addAll(c) ;
	}


}
